package com.guangdujs.kis.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guangdujs.common.annotation.Log;
import com.guangdujs.common.core.controller.BaseController;
import com.guangdujs.common.core.domain.AjaxResult;
import com.guangdujs.common.enums.BusinessType;
import com.guangdujs.kis.domain.KisUse;
import com.guangdujs.kis.service.IKisUseService;
import com.guangdujs.common.utils.poi.ExcelUtil;
import com.guangdujs.common.core.page.TableDataInfo;

/**
 * 正在使用的Controller
 * 
 * @author kis
 * @date 2022-10-31
 */
@RestController
@RequestMapping("/kis/use")
public class KisUseController extends BaseController
{
    @Autowired
    private IKisUseService kisUseService;

    /**
     * 查询正在使用的列表
     */
    @PreAuthorize("@ss.hasPermi('kis:use:list')")
    @GetMapping("/list")
    public TableDataInfo list(KisUse kisUse)
    {
        startPage();
        List<KisUse> list = kisUseService.selectKisUseList(kisUse);
        return getDataTable(list);
    }

    /**
     * 导出正在使用的列表
     */
    @PreAuthorize("@ss.hasPermi('kis:use:export')")
    @Log(title = "正在使用的", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KisUse kisUse)
    {
        List<KisUse> list = kisUseService.selectKisUseList(kisUse);
        ExcelUtil<KisUse> util = new ExcelUtil<KisUse>(KisUse.class);
        util.exportExcel(response, list, "正在使用的数据");
    }

    /**
     * 获取正在使用的详细信息
     */
    @PreAuthorize("@ss.hasPermi('kis:use:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(kisUseService.selectKisUseById(id));
    }

    /**
     * 新增正在使用的
     */
    @PreAuthorize("@ss.hasPermi('kis:use:add')")
    @Log(title = "正在使用的", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KisUse kisUse)
    {
        return toAjax(kisUseService.insertKisUse(kisUse));
    }

    /**
     * 修改正在使用的
     */
    @PreAuthorize("@ss.hasPermi('kis:use:edit')")
    @Log(title = "正在使用的", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KisUse kisUse)
    {
        return toAjax(kisUseService.updateKisUse(kisUse));
    }

    /**
     * 删除正在使用的
     */
    @PreAuthorize("@ss.hasPermi('kis:use:remove')")
    @Log(title = "正在使用的", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kisUseService.deleteKisUseByIds(ids));
    }
}
